<template>
	<div class="part">
	    <span>数据来源于vdr</span>
		<h2>YTD超速</h2>
		<div ref="speedingCountryChart" style="width:100%;height:20rem"></div>
		<div class="mt30" ref="speedingPersonalChart" style="width:100%;height:20rem"></div>
	</div>
</template>
<script type="text/javascript">
	import echarts from 'echarts'
	export default{
		mounted(){
			this.getSpeedingCountryData();
			this.getSpeedingPersonalData();
		},
		methods:{
			//超速
			getSpeedingCountryData(){
				let speedingCountryChart = echarts.init(this.$refs.speedingCountryChart);
				this.$http.get(this.$parent.speedingCountryUrl,{emulateJSON:true})
				.then((response) => {
					// console.log(response);
					if(response){
						this.$parent.speedingCountryOption.yAxis.data = response.data[0].type;
						this.$parent.speedingCountryOption.series[0].data = response.data[0].data[0];
						speedingCountryChart.setOption(this.$parent.speedingCountryOption);
					}
				})
			},
			getSpeedingPersonalData(){
				let speedingPersonalChart = echarts.init(this.$refs.speedingPersonalChart);
				this.$http.get(this.$parent.speedingPersonalUrl,{emulateJSON:true})
				.then((response) => {
					// console.log(response);
					if(response){
						let dataLen = response.data[0].data[0].length;
						this.$parent.speedingPersonalOption.xAxis.data[dataLen-1] = response.data[0].type[0];

						// this.$parent.speedingPersonalOption.xAxis.data = response.data[0].type;
						this.$parent.speedingPersonalOption.series.data = response.data[0].data[0];

						speedingPersonalChart.setOption(this.$parent.speedingPersonalOption);
					}
				})
			}
		}
	}
</script>